<#macro mapperEl value>${r"#{"}${value}}</#macro>
<#macro mapperEls>${r"#{item}"}</#macro>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="${mapperPackage}.${classNamed}Mapper" >
  <resultMap id="BaseResultMap" type="${pojoPackage}.${classNamed}" >
  <#list tableCarrays as tableCarray>	
  <#if (tableCarray_index=0)>
	 <id column="${tableCarray.carrayName}" property="${tableCarray.carrayNamex}" jdbcType="${tableCarray.columnType}" />
	</#if>
  </#list>
  <#list tableCarrays as tableCarray>	
  	<#if (tableCarray_index>=1)>
    <result column="${tableCarray.carrayName}" property="${tableCarray.carrayNamex}" jdbcType="${tableCarray.columnType}" />
  	</#if>
  </#list>
    </resultMap>
  <sql id="Base_Column_List" >
    ${stringCarrayNames3}
  </sql>
  
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from ${className}
    where 
     <#list tableCarrays as tableCarray>	
  		<#if (tableCarray_index=0)>
 	 		${tableCarray.carrayName} = <@mapperEl tableCarray.carrayNamex/> 
		</#if>
  </#list>    
    
  </select>
  
  <select id="selectAll" resultMap="BaseResultMap" >
    select 
    <include refid="Base_Column_List" />
    from ${className}   
  </select>
  <select id="selectAllBYCondition" resultType="map" parameterType="map" >
    select 
   <trim suffixOverrides="," >
   <#list tableCarrays as tableCarray>	   
		 ${tableCarray.carrayName} as ${tableCarray.carrayNamex},
  </#list>
   </trim>
    from ${className}   
  </select>
  
  <delete id="deleteByPrimaryKey">
    delete from ${className}    
    where 
     <#list tableCarrays as tableCarray>	
  		<#if (tableCarray_index=0)>
 	 		${tableCarray.carrayName} in
		</#if>
  </#list> 
  <foreach item="item" index="index" collection="array" open="(" separator="," close=")">
    	<@mapperEls/> 
   </foreach> 
  </delete>


  <insert id="insert" parameterType="${pojoPackage}.${classNamed}"  useGeneratedKeys="true" keyProperty="<#list tableCarrays as tableCarray><#if (tableCarray_index=0)>${tableCarray.carrayNamex}</#if></#list>" >
    insert into ${className} ( ${stringCarrayNames3})
    values (<#list tableCarrays as tableCarray><#if tableCarray_index==0 > <@mapperEl tableCarray.carrayNamex/><#else>,<@mapperEl tableCarray.carrayNamex/></#if></#list>)
  </insert>
  
  <insert id="insertSelective" parameterType="${pojoPackage}.${classNamed}"  useGeneratedKeys="true" keyProperty="<#list tableCarrays as tableCarray><#if (tableCarray_index=0)>${tableCarray.carrayNamex}</#if></#list>" >
    insert into ${className}
    <trim prefix="(" suffix=")" suffixOverrides="," >
    <#list tableCarrays as tableCarray>
      <if test="${tableCarray.carrayNamex} != null" >
        ${tableCarray.carrayName},
      </if>
    </#list>     
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
     <#list tableCarrays as tableCarray>
      <if test="${tableCarray.carrayNamex} != null" >
        <@mapperEl tableCarray.carrayNamex/>,
      </if>      
      </#list>   
    </trim>
  </insert>
  
  <update id="updateByPrimaryKeySelective" parameterType="${pojoPackage}.${classNamed}" >
    update ${className}
    <set >
     <#list tableCarrays as tableCarray>
     <#if (tableCarray_index>=1)>
      <if test="${tableCarray.carrayNamex} != null" >
        ${tableCarray.carrayName}=<@mapperEl tableCarray.carrayNamex/>,
      </if>
      </#if>
    </#list> 
    </set>
    where 
	<#list tableCarrays as tableCarray>	
  		<#if (tableCarray_index=0)>
 	 		${tableCarray.carrayName} = <@mapperEl tableCarray.carrayNamex/> 
		</#if>
  </#list>   
  </update>
  
  
  <update id="updateByPrimaryKey" parameterType="${pojoPackage}.${classNamed}" >
    update ${className}
    	set <#list tableCarrays as tableCarray><#if tableCarray_index==1>${tableCarray.carrayName}=<@mapperEl tableCarray.carrayNamex/><#elseif tableCarray_index!=0 >,${tableCarray.carrayName}=<@mapperEl tableCarray.carrayNamex/></#if></#list>
    	where
	    <#list tableCarrays as tableCarray>	
  		<#if (tableCarray_index=0)>
 	 		${tableCarray.carrayName} = <@mapperEl tableCarray.carrayNamex/> 
		</#if>
  </#list>  
  </update>
</mapper>